package com.rd.api;

import com.rd.service.IPhzhiService;
import com.rd.util.ResultModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 27949
 * @version 1.0
 * @date 2023/11/5 15:45
 */
@RestController
@RequestMapping("api/ph")
@Slf4j
public class PHConroller {

    @Resource
    private IPhzhiService phzhiService;

    @GetMapping("/showEcharts")
    public ResultModel showEcharts(){
        log.info("API---------------->showEcharts方法!");
        List<String> nameList = new ArrayList<>();
        List<String> numList = new ArrayList<>();
        for (int i = 1; i <= 12; i++) {
            nameList.add(i+"月");
            numList.add(String.valueOf(phzhiService.getPhzhi(i).getMaxph()));
        }
        return ResultModel.createBySuccess().put("nameList",nameList).put("numList",numList);
    }
}
